package com.one.group.admin.service.impl;


import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.one.group.admin.mapper.SpFloorMapper;
import com.one.group.model.entity.SpFloor;
import com.one.group.model.vo.FloorManagementVo;
import com.one.group.service.SpFloorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SpFloorServiceImpl extends ServiceImpl<SpFloorMapper, SpFloor> implements SpFloorService {
    @Override
    public List<FloorManagementVo> mylist(Long buildingId) {
        //构建查询条件
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(SpFloor::getBuildingId, buildingId);
        List<SpFloor> spFloors = this.list(queryWrapper);
        List<FloorManagementVo> floorManagementVos = new ArrayList<>();
        for (SpFloor spFloor : spFloors){
            FloorManagementVo floorManagementVo = new FloorManagementVo();
            floorManagementVo.setId(spFloor.getId());
            floorManagementVo.setName(spFloor.getName());
            floorManagementVos.add(floorManagementVo);
        }
        return floorManagementVos;
    }
}
